var app = getApp();
var time = require('../../utils/util.js');
Page({
  data: {
    register_role: null,

    clientHeight: '',
    mcon_height: 1600,
    winHeight: "", //窗口高度
    currentTab: 0, //预设当前项的值
    scrollLeft: 0, //tab标题的滚动条位置

    current_b_Tab: 0, //预设当前项的值  

    start_date: '', //时间戳
    end_date: '',

    p1_guilds: null,
    head_guild_name: null, //头部平台名字
    head_guild_id: null,

    guild_id: '',



    p1_top_name: null, //榜单增长名
    p1_top_data: null,
    p1_total_data: null,
    foot_name: null,

    index: 0,
    ids: 0,

    start_time: null, //开始时间、结束时间
    end_time: null,

    return_strat: null, //解析时间戳
    return_end: null,

    guild_id: null, //切换 输入公会id

    btn_l: '前一天',
    btn_r: '后一天',


    show_time: '',


    right_color: '#fff', //点击不了的颜色
    left_color: '#fff',


    show_wan: false,

    pj_total: 0, //拼接礼物数

    gift_pj_1: 0,
    gift_pj_2: "0",





    realTime: '',

    month_num: '',
    giftsmouth_l: '',
    giftsmouth_r: '',
    giftsmouth_all: '',


    table_flag: null,
    status: null,

    foot_indexs: null,

    kong: false,
    close: false,

  },

  preventTouchMove: function() {},
  click_more: function() {
    this.setData({
      close: true,
    })
  },
  click_close: function() {
    this.setData({
      close: false,
    })
  },
  add_guild: function() {
    wx.navigateTo({
      url: '../bindingGuild/index/index',
    })
  },
  upgrade_guild: function() {
    wx.navigateTo({
      url: '../bindingGuild/President/authenticate/authenticate?guild_id=' + this.data.guild_id + '&&guild_name=' + this.data.guild_name + '&&type=upgrade',
    })
  },
  add_anchor: function() {
    wx.navigateTo({
      url: '../bindingGuild/anchor/binding/binding?title=添加主播',
    })
  },
  goGuild: function() {
    wx.navigateTo({
      url: '../mine/guildManage/guildManage',
    })
  },
  goAUth: function(e) {
    console.log(e)
    let guild_id = e.currentTarget.dataset.guild_id;
    let guild_name = e.currentTarget.dataset.guild_name;
    wx.navigateTo({
      url: '../bindingGuild/President/authenticate/authenticate?guild_id=' + guild_id + '&&guild_name=' + guild_name + '&&platfrom_name=' + guild_name + '&&type=verification',
    })
  },





  //左按钮
  click_l: function() {
    this.setData({
      right_color: '#fff',
      pj_total: '',
    })


    wx.showLoading({
      title: '小主稍等~',
    })
    var that = this;
    if (this.data.btn_l == '前一天') {
      app.globalData.start_date = app.globalData.start_date - 86400;
      app.globalData.end_date = app.globalData.end_date - 86400;
      //点击开始

      //角色编号、日期转换
      this.setData({
        register_role: app.register_info.register_role,

        start_date: app.globalData.start_date,
        end_date: app.globalData.end_date

      })
      if (app.globalData.flag == "day") {
        this.setData({
          start_time: time.formatTimeTwo(app.globalData.start_date, 'Y年M月D日'),
          end_time: time.formatTimeTwo(app.globalData.end_date, 'Y年M月D日')
        })
      }
      if (app.globalData.flag == "week") {
        this.setData({
          start_time: time.formatTimeTwo(app.globalData.start_date, 'M月D日'),
          end_time: time.formatTimeTwo(app.globalData.end_date, 'M月D日')
        })
      }
      if (app.globalData.flag == "other") {
        this.setData({
          start_time: time.formatTimeTwo(app.globalData.start_date, 'M月D日'),
          end_time: time.formatTimeTwo(app.globalData.end_date, 'M月D日')
        })
      }
      if (app.globalData.flag == "month") {
        this.setData({
          start_time: time.formatTimeTwo(app.globalData.start_date, 'Y年M月'),
          end_time: time.formatTimeTwo(app.globalData.end_date, 'Y年M月')
        })
      }

      // console.log(this.data.start_time),
      // console.log(this.data.end_time)


      //  高度自适应


      // if (app.register_info.register_role == 1) {
      //头部数据
      if (this.data.table_flag) {
        wx.request({
          method: 'POST',
          url: app.globalData.url + 'api/report/index/mainnew',
          data: {
            token: app.globalData.token,
            guild_id: this.data.guild_id,
            start_date: this.data.start_date,
            end_date: this.data.end_date,
            quick: "1",
            table_flag: this.data.table_flag,
          },
          success: function(e) {
            // console.log(e.data.data)
            var giftsmouth = e.data.data.total_data.giftsmouth.data;


            if (giftsmouth.length > 4) {
              var giftsmouth_r = giftsmouth.slice(-4).slice(0, 1)
              var giftsmouth_l = giftsmouth.slice(0, -4)
              // console.log(giftsmouth_r)
              // console.log(giftsmouth_l)
              var giftsmouth_all = giftsmouth_l + '.' + giftsmouth_r + "万"
              that.setData({
                giftsmouth_l: giftsmouth_l,
                giftsmouth_r: giftsmouth_r,
                giftsmouth_all: giftsmouth_all
              })
              console.log(giftsmouth_all)
            } else {
              that.setData({
                giftsmouth_all: e.data.data.total_data.giftsmouth.data
              })
            }

            //push合成新数组
            var guilds = e.data.data.guilds;
            var quick_guild = e.data.data.quick_guild;
            var p1_guilds = [];
            p1_guilds.push(...guilds)
            p1_guilds.push(...quick_guild)

            that.setData({
              p1_guilds: p1_guilds,
              p1_total_data: e.data.data.total_data,
              // month_num:
            })
            if (e.data.data.total_data.income_diamond) {
              var diamond_int = parseInt(e.data.data.total_data.income_diamond.data)
              var diamond_ceil = Math.ceil(diamond_int).toString()
              that.setData({
                pj_total: diamond_ceil
              })

            } else {
              var gift_int = parseInt(e.data.data.total_data.gifts.data)
              var gift_ceil = Math.ceil(gift_int).toString()
              that.setData({
                pj_total: gift_ceil
              })
            }
            // console.log(that.data.pj_total);
            if (that.data.pj_total.length > 4) {

              var gift_pj_1 = that.data.pj_total.slice(-4); //后面四位
              var gift_pj_2 = that.data.pj_total.slice(0, -4) + '.'
              // console.log('显示万')
              if (that.data.pj_total.length >= 9) {
                that.setData({
                  show_yi: true
                })
              } else {
                // console.log('隐藏亿')
                that.setData({
                  show_yi: false
                })
              }
              that.setData({
                show_wan: true,
                gift_pj_1: gift_pj_1,
                gift_pj_2: gift_pj_2
              })
            } else {
              // console.log('不到万，走这里')
              // console.log('隐藏万')
              that.setData({
                show_wan: false,
                gift_pj_1: '',
                gift_pj_2: that.data.pj_total
              })
              // console.log(that.data.show_wan)
            }


          }
        });
      } else {
        wx.request({
          method: 'POST',
          url: app.globalData.url + 'api/report/index/mainnew',
          data: {
            token: app.globalData.token,
            guild_id: this.data.guild_id,
            start_date: this.data.start_date,
            end_date: this.data.end_date
          },
          success: function(e) {
            // console.log(e.data.data)
            var giftsmouth = e.data.data.total_data.giftsmouth.data;


            if (giftsmouth.length > 4) {
              var giftsmouth_r = giftsmouth.slice(-4).slice(0, 1)
              var giftsmouth_l = giftsmouth.slice(0, -4)
              // console.log(giftsmouth_r)
              // console.log(giftsmouth_l)
              var giftsmouth_all = giftsmouth_l + '.' + giftsmouth_r + "万"
              that.setData({
                giftsmouth_l: giftsmouth_l,
                giftsmouth_r: giftsmouth_r,
                giftsmouth_all: giftsmouth_all
              })
              console.log(giftsmouth_all)
            } else {
              that.setData({
                giftsmouth_all: e.data.data.total_data.giftsmouth.data
              })
            }

            //push合成新数组
            var guilds = e.data.data.guilds;
            var quick_guild = e.data.data.quick_guild;
            var p1_guilds = [];
            p1_guilds.push(...guilds)
            p1_guilds.push(...quick_guild)

            that.setData({
              p1_guilds: p1_guilds,
              p1_total_data: e.data.data.total_data,
              // month_num:
            })
            if (e.data.data.total_data.income_diamond) {
              var diamond_int = parseInt(e.data.data.total_data.income_diamond.data)
              var diamond_ceil = Math.ceil(diamond_int).toString()
              that.setData({
                pj_total: diamond_ceil
              })

            } else {
              var gift_int = parseInt(e.data.data.total_data.gifts.data)
              var gift_ceil = Math.ceil(gift_int).toString()
              that.setData({
                pj_total: gift_ceil
              })
            }
            // console.log(that.data.pj_total);
            if (that.data.pj_total.length > 4) {

              var gift_pj_1 = that.data.pj_total.slice(-4); //后面四位
              var gift_pj_2 = that.data.pj_total.slice(0, -4) + '.'
              // console.log('显示万')
              if (that.data.pj_total.length >= 9) {
                that.setData({
                  show_yi: true
                })
              } else {
                // console.log('隐藏亿')
                that.setData({
                  show_yi: false
                })
              }
              that.setData({
                show_wan: true,
                gift_pj_1: gift_pj_1,
                gift_pj_2: gift_pj_2
              })
            } else {
              // console.log('不到万，走这里')
              // console.log('隐藏万')
              that.setData({
                show_wan: false,
                gift_pj_1: '',
                gift_pj_2: that.data.pj_total
              })
              // console.log(that.data.show_wan)
            }


          }
        });
      }

      //排行数据
      if (app.register_info.register_role == 2) {
        if (this.data.table_flag) {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/topnew',
            data: {
              guild_id: this.data.guild_id,
              token: app.globalData.token,
              start_date: this.data.start_date,
              end_date: this.data.end_date,
              quick: "1",
              table_flag: this.data.table_flag,
            },
            success: function(e) {
              // console.log(e)
              var p1_top_data = e.data.data.anchor_top[that.data.index].data.data;
              var p1_top_name = e.data.data.anchor_top[that.data.index].name;
              var foot_name = e.data.data.anchor_top;
              // console.log(foot_name)
              that.setData({
                p1_top_data: p1_top_data,
                p1_top_name: p1_top_name,
                foot_name: foot_name
              })
              wx.hideLoading()
            }

          })
        } else {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/topnew',
            data: {
              guild_id: this.data.guild_id,
              token: app.globalData.token,
              start_date: this.data.start_date,
              end_date: this.data.end_date
            },
            success: function(e) {
              console.log(e)
              var p1_top_data = e.data.data.top_data[that.data.index].data.data;
              var p1_top_name = e.data.data.top_data[that.data.index].name;
              var foot_name = e.data.data.top_data;
              // console.log(foot_name)
              that.setData({
                p1_top_data: p1_top_data,
                p1_top_name: p1_top_name,
                foot_name: foot_name
              })
              wx.hideLoading()
            }

          })
        }
      } else {
        if (this.data.table_flag) {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/topnew',
            data: {
              guild_id: this.data.guild_id,
              token: app.globalData.token,
              start_date: this.data.start_date,
              end_date: this.data.end_date,
              quick: "1",
              table_flag: this.data.table_flag,
            },
            success: function(e) {
              var p1_top_data = e.data.data.top_data[that.data.index].data.data;
              var p1_top_name = e.data.data.top_data[that.data.index].name;
              var foot_name = e.data.data.top_data;
              // console.log(foot_name)
              that.setData({
                p1_top_data: p1_top_data,
                p1_top_name: p1_top_name,
                foot_name: foot_name
              })
              wx.hideLoading()
            }

          })
        } else {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/topnew',
            data: {
              guild_id: this.data.guild_id,
              token: app.globalData.token,
              start_date: this.data.start_date,
              end_date: this.data.end_date
            },
            success: function(e) {
              console.log(e)
              var p1_top_data = e.data.data.top_data[that.data.index].data.data;
              var p1_top_name = e.data.data.top_data[that.data.index].name;
              var foot_name = e.data.data.top_data;
              // console.log(foot_name)
              that.setData({
                p1_top_data: p1_top_data,
                p1_top_name: p1_top_name,
                foot_name: foot_name
              })
              wx.hideLoading()
            }

          })
        }

        var date = new Date();
        var nowtime = date.getFullYear() + '/' + ((date.getMonth() + 1) > 10 ? (date.getMonth() + 1) : "0" + (date.getMonth() + 1)) + '/' + (date.getDate() > 10 ? (date.getDate()) : '0' + (date.getDate()))
        var test = Date.parse(nowtime) / 1000
        if (app.globalData.start_date == test) {
          console.log("今日")
        }
      }
      //点击结束



    } else if (this.data.btn_l == '前一周') {
      // console.log("点击周")
      app.globalData.start_date = app.globalData.start_date - 86400 * 7;
      app.globalData.end_date = app.globalData.end_date - 86400 * 7
      //角色编号、日期转换
      this.setData({
        register_role: app.register_info.register_role,

        start_date: app.globalData.start_date,
        end_date: app.globalData.end_date

      })
      if (app.globalData.flag == "day") {
        this.setData({
          start_time: time.formatTimeTwo(app.globalData.start_date, 'Y年M月D日'),
          end_time: time.formatTimeTwo(app.globalData.end_date, 'Y年M月D日')
        })
      }
      if (app.globalData.flag == "week") {
        this.setData({
          start_time: time.formatTimeTwo(app.globalData.start_date, 'M月D日'),
          end_time: time.formatTimeTwo(app.globalData.end_date, 'M月D日')
        })
      }
      if (app.globalData.flag == "other") {
        this.setData({
          start_time: time.formatTimeTwo(app.globalData.start_date, 'M月D日'),
          end_time: time.formatTimeTwo(app.globalData.end_date, 'M月D日')
        })
      }
      if (app.globalData.flag == "month") {
        this.setData({
          start_time: time.formatTimeTwo(app.globalData.start_date, 'Y年M月'),
          end_time: time.formatTimeTwo(app.globalData.end_date, 'Y年M月')
        })
      }

      // console.log(this.data.start_time),
      // console.log(this.data.end_time)


      //  高度自适应



      // if (app.register_info.register_role == 1) {
      //头部数据
      if (this.data.table_flag) {
        wx.request({
          method: 'POST',
          url: app.globalData.url + 'api/report/index/mainnew',
          data: {
            token: app.globalData.token,
            guild_id: this.data.guild_id,
            start_date: this.data.start_date,
            end_date: this.data.end_date,
            quick: "1",
            table_flag: this.data.table_flag,
          },
          success: function(e) {
            // console.log(e.data.data)

            var giftsmouth = e.data.data.total_data.giftsmouth.data;


            if (giftsmouth.length > 4) {
              var giftsmouth_r = giftsmouth.slice(-4).slice(0, 1)
              var giftsmouth_l = giftsmouth.slice(0, -4)
              // console.log(giftsmouth_r)
              // console.log(giftsmouth_l)
              var giftsmouth_all = giftsmouth_l + '.' + giftsmouth_r + "万"
              that.setData({
                giftsmouth_l: giftsmouth_l,
                giftsmouth_r: giftsmouth_r,
                giftsmouth_all: giftsmouth_all
              })
              console.log(giftsmouth_all)
            } else {
              that.setData({
                giftsmouth_all: e.data.data.total_data.giftsmouth.data
              })
            }

            //push合成新数组
            var guilds = e.data.data.guilds;
            var quick_guild = e.data.data.quick_guild;
            var p1_guilds = [];
            p1_guilds.push(...guilds)
            p1_guilds.push(...quick_guild)

            that.setData({
              p1_guilds: p1_guilds,
              p1_total_data: e.data.data.total_data
            })
            if (e.data.data.total_data.income_diamond) {
              var diamond_int = parseInt(e.data.data.total_data.income_diamond.data)
              var diamond_ceil = Math.ceil(diamond_int).toString()
              that.setData({
                pj_total: diamond_ceil
              })

            } else {
              var gift_int = parseInt(e.data.data.total_data.gifts.data)
              var gift_ceil = Math.ceil(gift_int).toString()
              that.setData({
                pj_total: gift_ceil
              })
            }
            // console.log(that.data.pj_total);
            if (that.data.pj_total.length > 4) {

              var gift_pj_1 = that.data.pj_total.slice(-4); //后面四位
              var gift_pj_2 = that.data.pj_total.slice(0, -4) + '.'
              // console.log('显示万')
              if (that.data.pj_total.length >= 9) {
                that.setData({
                  show_yi: true
                })
              } else {
                // console.log('隐藏亿')
                that.setData({
                  show_yi: false
                })
              }
              that.setData({
                show_wan: true,
                gift_pj_1: gift_pj_1,
                gift_pj_2: gift_pj_2
              })
            } else {
              // console.log('不到万，走这里')
              // console.log('隐藏万')
              that.setData({
                show_wan: false,
                gift_pj_1: '',
                gift_pj_2: that.data.pj_total
              })
              // console.log(that.data.show_wan)
            }
          }
        });
      } else {
        wx.request({
          method: 'POST',
          url: app.globalData.url + 'api/report/index/mainnew',
          data: {
            token: app.globalData.token,
            guild_id: this.data.guild_id,
            start_date: this.data.start_date,
            end_date: this.data.end_date
          },
          success: function(e) {
            // console.log(e.data.data)

            var giftsmouth = e.data.data.total_data.giftsmouth.data;


            if (giftsmouth.length > 4) {
              var giftsmouth_r = giftsmouth.slice(-4).slice(0, 1)
              var giftsmouth_l = giftsmouth.slice(0, -4)
              // console.log(giftsmouth_r)
              // console.log(giftsmouth_l)
              var giftsmouth_all = giftsmouth_l + '.' + giftsmouth_r + "万"
              that.setData({
                giftsmouth_l: giftsmouth_l,
                giftsmouth_r: giftsmouth_r,
                giftsmouth_all: giftsmouth_all
              })
              console.log(giftsmouth_all)
            } else {
              that.setData({
                giftsmouth_all: e.data.data.total_data.giftsmouth.data
              })
            }

            //push合成新数组
            var guilds = e.data.data.guilds;
            var quick_guild = e.data.data.quick_guild;
            var p1_guilds = [];
            p1_guilds.push(...guilds)
            p1_guilds.push(...quick_guild)

            that.setData({
              p1_guilds: p1_guilds,
              p1_total_data: e.data.data.total_data
            })
            if (e.data.data.total_data.income_diamond) {
              var diamond_int = parseInt(e.data.data.total_data.income_diamond.data)
              var diamond_ceil = Math.ceil(diamond_int).toString()
              that.setData({
                pj_total: diamond_ceil
              })

            } else {
              var gift_int = parseInt(e.data.data.total_data.gifts.data)
              var gift_ceil = Math.ceil(gift_int).toString()
              that.setData({
                pj_total: gift_ceil
              })
            }
            // console.log(that.data.pj_total);
            if (that.data.pj_total.length > 4) {

              var gift_pj_1 = that.data.pj_total.slice(-4); //后面四位
              var gift_pj_2 = that.data.pj_total.slice(0, -4) + '.'
              // console.log('显示万')
              if (that.data.pj_total.length >= 9) {
                that.setData({
                  show_yi: true
                })
              } else {
                // console.log('隐藏亿')
                that.setData({
                  show_yi: false
                })
              }
              that.setData({
                show_wan: true,
                gift_pj_1: gift_pj_1,
                gift_pj_2: gift_pj_2
              })
            } else {
              // console.log('不到万，走这里')
              // console.log('隐藏万')
              that.setData({
                show_wan: false,
                gift_pj_1: '',
                gift_pj_2: that.data.pj_total
              })
              // console.log(that.data.show_wan)
            }
          }
        });
      }

      //排行数据
      if (app.register_info.register_role == 2) {
        if (this.data.table_flag) {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/topnew',
            data: {
              guild_id: this.data.guild_id,
              token: app.globalData.token,
              start_date: this.data.start_date,
              end_date: this.data.end_date,
              quick: "1",
              table_flag: this.data.table_flag,
            },
            success: function(e) {
              // console.log(e)
              var p1_top_data = e.data.data.anchor_top[that.data.index].data.data;
              var p1_top_name = e.data.data.anchor_top[that.data.index].name;
              var foot_name = e.data.data.anchor_top;
              // console.log(foot_name)
              that.setData({
                p1_top_data: p1_top_data,
                p1_top_name: p1_top_name,
                foot_name: foot_name
              })
              wx.hideLoading()
            }

          })
        } else {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/topnew',
            data: {
              guild_id: this.data.guild_id,
              token: app.globalData.token,
              start_date: this.data.start_date,
              end_date: this.data.end_date
            },
            success: function(e) {
              console.log(e)
              var p1_top_data = e.data.data.top_data[that.data.index].data.data;
              var p1_top_name = e.data.data.top_data[that.data.index].name;
              var foot_name = e.data.data.top_data;
              // console.log(foot_name)
              that.setData({
                p1_top_data: p1_top_data,
                p1_top_name: p1_top_name,
                foot_name: foot_name
              })
              wx.hideLoading()
            }

          })
        }
      } else {
        if (this.data.table_flag) {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/topnew',
            data: {
              guild_id: this.data.guild_id,
              token: app.globalData.token,
              start_date: this.data.start_date,
              end_date: this.data.end_date,
              quick: "1",
              table_flag: this.data.table_flag,
            },
            success: function(e) {
              var p1_top_data = e.data.data.top_data[that.data.index].data.data;
              var p1_top_name = e.data.data.top_data[that.data.index].name;
              var foot_name = e.data.data.top_data;
              // console.log(foot_name)
              that.setData({
                p1_top_data: p1_top_data,
                p1_top_name: p1_top_name,
                foot_name: foot_name
              })
              wx.hideLoading()
            }

          })
        } else {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/topnew',
            data: {
              guild_id: this.data.guild_id,
              token: app.globalData.token,
              start_date: this.data.start_date,
              end_date: this.data.end_date
            },
            success: function(e) {
              var p1_top_data = e.data.data.top_data[that.data.index].data.data;
              var p1_top_name = e.data.data.top_data[that.data.index].name;
              var foot_name = e.data.data.top_data;
              // console.log(foot_name)
              that.setData({
                p1_top_data: p1_top_data,
                p1_top_name: p1_top_name,
                foot_name: foot_name
              })
              wx.hideLoading()
            }

          })
        }

      }

    } else if (this.data.btn_l == '前一月') {
      console.log("点击月");
      var get_month = this.data.start_time.slice(5, 7);
      var get_year = this.data.start_time.split("/")[0]

      // console.log(get_year)
      switch (get_month) {
        case "01":
          if ((get_year % 4 == 0) && (get_year % 100 != 0 || get_year % 400 == 0)) {
            //闰年
            app.globalData.start_date = app.globalData.start_date - 86400 * 31;
            app.globalData.end_date = app.globalData.end_date - 86400 * 31;
            // console.log(app.globalData.start_date);
            break;
          } else {
            //平年
            app.globalData.start_date = app.globalData.start_date - 86400 * 31;
            app.globalData.end_date = app.globalData.end_date - 86400 * 31;
            // console.log(app.globalData.start_date);
            break;
          }

          // console.log(app.globalData.start_date);
          break;
        case "02":
          if ((get_year % 4 == 0) && (get_year % 100 != 0 || get_year % 400 == 0)) {
            //闰年
            app.globalData.start_date = app.globalData.start_date - 86400 * 31;
            app.globalData.end_date = app.globalData.end_date - 86400 * 29;
            // console.log(app.globalData.start_date);
            break;
          } else {
            //平年
            app.globalData.start_date = app.globalData.start_date - 86400 * 31;
            app.globalData.end_date = app.globalData.end_date - 86400 * 28;
            // console.log(app.globalData.start_date);
            break;
          }

        case "03":
          if ((get_year % 4 == 0) && (get_year % 100 != 0 || get_year % 400 == 0)) {
            //闰年
            app.globalData.start_date = app.globalData.start_date - 86400 * 29;
            app.globalData.end_date = app.globalData.end_date - 86400 * 31;
            // console.log(app.globalData.start_date);
            break;
          } else {
            //平年
            app.globalData.start_date = app.globalData.start_date - 86400 * 28;
            app.globalData.end_date = app.globalData.end_date - 86400 * 31;
            // console.log(app.globalData.start_date);
            break;
          }
        case "04":
          app.globalData.start_date = app.globalData.start_date - 86400 * 31;
          app.globalData.end_date = app.globalData.end_date - 86400 * 30;
          // console.log(app.globalData.start_date);
          break;
        case "05":
          app.globalData.start_date = app.globalData.start_date - 86400 * 30;
          app.globalData.end_date = app.globalData.end_date - 86400 * 31;
          // console.log(app.globalData.start_date);
          break;
        case "06":
          app.globalData.start_date = app.globalData.start_date - 86400 * 31;
          app.globalData.end_date = app.globalData.end_date - 86400 * 30;
          // console.log(app.globalData.start_date);
          break;
        case "07":
          app.globalData.start_date = app.globalData.start_date - 86400 * 30;
          app.globalData.end_date = app.globalData.end_date - 86400 * 31;
          // console.log(app.globalData.start_date);
          break;
        case "08":
          app.globalData.start_date = app.globalData.start_date - 86400 * 31;
          app.globalData.end_date = app.globalData.end_date - 86400 * 31;
          // console.log(app.globalData.start_date);
          break;
        case "09":
          app.globalData.start_date = app.globalData.start_date - 86400 * 31;
          app.globalData.end_date = app.globalData.end_date - 86400 * 30;
          // console.log(app.globalData.start_date);
          break;
        case "10":
          app.globalData.start_date = app.globalData.start_date - 86400 * 30;
          app.globalData.end_date = app.globalData.end_date - 86400 * 31;
          // console.log(app.globalData.start_date);
          break;
        case "11":
          app.globalData.start_date = app.globalData.start_date - 86400 * 31;
          app.globalData.end_date = app.globalData.end_date - 86400 * 30;
          // console.log(app.globalData.start_date);
          break;
        case "12":
          app.globalData.start_date = app.globalData.start_date - 86400 * 30;
          app.globalData.end_date = app.globalData.end_date - 86400 * 31;
          // console.log(app.globalData.start_date);
          break;

      }
      //结束判断
      //点击开始

      //角色编号、日期转换
      this.setData({
        register_role: app.register_info.register_role,

        start_date: app.globalData.start_date,
        end_date: app.globalData.end_date

      })
      if (app.globalData.flag == "day") {
        this.setData({
          start_time: time.formatTimeTwo(app.globalData.start_date, 'Y年M月D日'),
          end_time: time.formatTimeTwo(app.globalData.end_date, 'Y年M月D日')
        })
      }
      if (app.globalData.flag == "week") {
        this.setData({
          start_time: time.formatTimeTwo(app.globalData.start_date, 'M月D日'),
          end_time: time.formatTimeTwo(app.globalData.end_date, 'M月D日')
        })
      }
      if (app.globalData.flag == "other") {
        this.setData({
          start_time: time.formatTimeTwo(app.globalData.start_date, 'M月D日'),
          end_time: time.formatTimeTwo(app.globalData.end_date, 'M月D日')
        })
      }
      if (app.globalData.flag == "month") {
        this.setData({
          start_time: time.formatTimeTwo(app.globalData.start_date, 'Y年M月'),
          end_time: time.formatTimeTwo(app.globalData.end_date, 'Y年M月')
        })
      }

      // console.log(this.data.start_time),
      // console.log(this.data.end_time)


      //  高度自适应



      // if (app.register_info.register_role == 1) {
      //头部数据
      if (this.data.table_flag) {
        wx.request({
          method: 'POST',
          url: app.globalData.url + 'api/report/index/mainnew',
          data: {
            token: app.globalData.token,
            guild_id: this.data.guild_id,
            start_date: this.data.start_date,
            end_date: this.data.end_date,
            quick: "1",
            table_flag: this.data.table_flag,
          },
          success: function(e) {
            var giftsmouth = e.data.data.total_data.giftsmouth.data;


            if (giftsmouth.length > 4) {
              var giftsmouth_r = giftsmouth.slice(-4).slice(0, 1)
              var giftsmouth_l = giftsmouth.slice(0, -4)
              // console.log(giftsmouth_r)
              // console.log(giftsmouth_l)
              var giftsmouth_all = giftsmouth_l + '.' + giftsmouth_r + "万"
              that.setData({
                giftsmouth_l: giftsmouth_l,
                giftsmouth_r: giftsmouth_r,
                giftsmouth_all: giftsmouth_all
              })
              console.log(giftsmouth_all)
            } else {
              that.setData({
                giftsmouth_all: e.data.data.total_data.giftsmouth.data
              })
            }
            // console.log(e.data.data)

            //push合成新数组
            var guilds = e.data.data.guilds;
            var quick_guild = e.data.data.quick_guild;
            var p1_guilds = [];
            p1_guilds.push(...guilds)
            p1_guilds.push(...quick_guild)

            that.setData({
              p1_guilds: p1_guilds,
              p1_total_data: e.data.data.total_data,
            })
            if (e.data.data.total_data.income_diamond) {
              var diamond_int = parseInt(e.data.data.total_data.income_diamond.data)
              var diamond_ceil = Math.ceil(diamond_int).toString()
              that.setData({
                pj_total: diamond_ceil
              })

            } else {
              var gift_int = parseInt(e.data.data.total_data.gifts.data)
              var gift_ceil = Math.ceil(gift_int).toString()
              that.setData({
                pj_total: gift_ceil
              })
            }
            // console.log(that.data.pj_total);
            if (that.data.pj_total.length > 4) {

              var gift_pj_1 = that.data.pj_total.slice(-4); //后面四位
              var gift_pj_2 = that.data.pj_total.slice(0, -4) + '.'
              // console.log('显示万')
              if (that.data.pj_total.length >= 9) {
                that.setData({
                  show_yi: true
                })
              } else {
                // console.log('隐藏亿')
                that.setData({
                  show_yi: false
                })
              }
              that.setData({
                show_wan: true,
                gift_pj_1: gift_pj_1,
                gift_pj_2: gift_pj_2
              })
            } else {
              // console.log('不到万，走这里')
              // console.log('隐藏万')
              that.setData({
                show_wan: false,
                gift_pj_1: '',
                gift_pj_2: that.data.pj_total
              })
              // console.log(that.data.show_wan)
            }
          }
        });
      } else {
        wx.request({
          method: 'POST',
          url: app.globalData.url + 'api/report/index/mainnew',
          data: {
            token: app.globalData.token,
            guild_id: this.data.guild_id,
            start_date: this.data.start_date,
            end_date: this.data.end_date
          },
          success: function(e) {
            var giftsmouth = e.data.data.total_data.giftsmouth.data;


            if (giftsmouth.length > 4) {
              var giftsmouth_r = giftsmouth.slice(-4).slice(0, 1)
              var giftsmouth_l = giftsmouth.slice(0, -4)
              // console.log(giftsmouth_r)
              // console.log(giftsmouth_l)
              var giftsmouth_all = giftsmouth_l + '.' + giftsmouth_r + "万"
              that.setData({
                giftsmouth_l: giftsmouth_l,
                giftsmouth_r: giftsmouth_r,
                giftsmouth_all: giftsmouth_all
              })
              console.log(giftsmouth_all)
            } else {
              that.setData({
                giftsmouth_all: e.data.data.total_data.giftsmouth.data
              })
            }
            // console.log(e.data.data)

            //push合成新数组
            var guilds = e.data.data.guilds;
            var quick_guild = e.data.data.quick_guild;
            var p1_guilds = [];
            p1_guilds.push(...guilds)
            p1_guilds.push(...quick_guild)

            that.setData({
              p1_guilds: p1_guilds,
              p1_total_data: e.data.data.total_data,
            })
            if (e.data.data.total_data.income_diamond) {
              var diamond_int = parseInt(e.data.data.total_data.income_diamond.data)
              var diamond_ceil = Math.ceil(diamond_int).toString()
              that.setData({
                pj_total: diamond_ceil
              })

            } else {
              var gift_int = parseInt(e.data.data.total_data.gifts.data)
              var gift_ceil = Math.ceil(gift_int).toString()
              that.setData({
                pj_total: gift_ceil
              })
            }
            // console.log(that.data.pj_total);
            if (that.data.pj_total.length > 4) {

              var gift_pj_1 = that.data.pj_total.slice(-4); //后面四位
              var gift_pj_2 = that.data.pj_total.slice(0, -4) + '.'
              // console.log('显示万')
              if (that.data.pj_total.length >= 9) {
                that.setData({
                  show_yi: true
                })
              } else {
                // console.log('隐藏亿')
                that.setData({
                  show_yi: false
                })
              }
              that.setData({
                show_wan: true,
                gift_pj_1: gift_pj_1,
                gift_pj_2: gift_pj_2
              })
            } else {
              // console.log('不到万，走这里')
              // console.log('隐藏万')
              that.setData({
                show_wan: false,
                gift_pj_1: '',
                gift_pj_2: that.data.pj_total
              })
              // console.log(that.data.show_wan)
            }
          }
        });
      }

      //排行数据
      if (app.register_info.register_role == 2) {
        if (this.data.table_flag) {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/topnew',
            data: {
              guild_id: this.data.guild_id,
              token: app.globalData.token,
              start_date: this.data.start_date,
              end_date: this.data.end_date,
              quick: "1",
              table_flag: this.data.table_flag,
            },
            success: function(e) {
              // console.log(e)
              var p1_top_data = e.data.data.anchor_top[that.data.index].data.data;
              var p1_top_name = e.data.data.anchor_top[that.data.index].name;
              var foot_name = e.data.data.anchor_top;
              // console.log(foot_name)
              that.setData({
                p1_top_data: p1_top_data,
                p1_top_name: p1_top_name,
                foot_name: foot_name
              })
              wx.hideLoading()
            }

          })
        } else {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/topnew',
            data: {
              guild_id: this.data.guild_id,
              token: app.globalData.token,
              start_date: this.data.start_date,
              end_date: this.data.end_date
            },
            success: function(e) {
              console.log(e)
              var p1_top_data = e.data.data.top_data[that.data.index].data.data;
              var p1_top_name = e.data.data.top_data[that.data.index].name;
              var foot_name = e.data.data.top_data;
              // console.log(foot_name)
              that.setData({
                p1_top_data: p1_top_data,
                p1_top_name: p1_top_name,
                foot_name: foot_name
              })
              wx.hideLoading()
            }

          })
        }
      } else {
        if (this.data.table_flag) {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/topnew',
            data: {
              guild_id: this.data.guild_id,
              token: app.globalData.token,
              start_date: this.data.start_date,
              end_date: this.data.end_date,
              quick: 1,
              table_flag: this.data.table_flag,
            },
            success: function(e) {
              var p1_top_data = e.data.data.top_data[that.data.index].data.data;
              var p1_top_name = e.data.data.top_data[that.data.index].name;
              var foot_name = e.data.data.top_data;
              // console.log(foot_name)
              that.setData({
                p1_top_data: p1_top_data,
                p1_top_name: p1_top_name,
                foot_name: foot_name
              })
              wx.hideLoading()
            }

          })
        } else {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/topnew',
            data: {
              guild_id: this.data.guild_id,
              token: app.globalData.token,
              start_date: this.data.start_date,
              end_date: this.data.end_date
            },
            success: function(e) {
              var p1_top_data = e.data.data.top_data[that.data.index].data.data;
              var p1_top_name = e.data.data.top_data[that.data.index].name;
              var foot_name = e.data.data.top_data;
              // console.log(foot_name)
              that.setData({
                p1_top_data: p1_top_data,
                p1_top_name: p1_top_name,
                foot_name: foot_name
              })
              wx.hideLoading()
            }

          })
        }

      }

      //点击结束

    }
  },
  //右按钮
  click_r: function() {
    this.setData({
      pj_total: '',
    })
    console.log("flag+" + app.globalData.flag)
    wx.showLoading({
      title: '小主稍等~',
    })



    var that = this;
    if (this.data.btn_r == '后一天') {
      console.log(this.data.guild_id)
      // console.log("点击天")
      var myDate = new Date();
      var panduan = Date.parse(myDate.toLocaleDateString()) / 1000;

      if (panduan <= app.globalData.start_date) {
        this.setData({
          right_color: '#666',
        })
        wx.hideLoading()
        return false;

      } else {
        this.setData({
          right_color: '#fff'
        })

        app.globalData.start_date = parseFloat(app.globalData.start_date) + 86400;
        app.globalData.end_date = parseFloat(app.globalData.end_date) + 86400
        // console.log('global+' + app.globalData.start_date)
        // console.log('global+' + app.globalData.end_date)

        //点击开始

        //角色编号、日期转换
        this.setData({

          start_date: app.globalData.start_date,
          end_date: app.globalData.end_date


        })
        if (app.globalData.flag == "day") {
          this.setData({
            start_time: time.formatTimeTwo(app.globalData.start_date, 'Y年M月D日'),
            end_time: time.formatTimeTwo(app.globalData.end_date, 'Y年M月D日')
          })
        }
        if (app.globalData.flag == "week") {
          this.setData({
            start_time: time.formatTimeTwo(app.globalData.start_date, 'M月D日'),
            end_time: time.formatTimeTwo(app.globalData.end_date, 'M月D日')
          })
        }
        if (app.globalData.flag == "other") {
          this.setData({
            start_time: time.formatTimeTwo(app.globalData.start_date, 'M月D日'),
            end_time: time.formatTimeTwo(app.globalData.end_date, 'M月D日')
          })
        }
        if (app.globalData.flag == "month") {
          this.setData({
            start_time: time.formatTimeTwo(app.globalData.start_date, 'Y年M月'),
            end_time: time.formatTimeTwo(app.globalData.end_date, 'Y年M月')
          })
        }
        console.log(this.data.start_time),
          console.log(this.data.end_time)


        //  高度自适应


        // if (app.register_info.register_role == 1) {
        //头部数据
        if (this.data.table_flag) {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/mainnew',
            data: {
              token: app.globalData.token,
              guild_id: this.data.guild_id,
              start_date: this.data.start_date,
              end_date: this.data.end_date,
              quick: "1",
              table_flag: this.data.table_flag,
            },
            success: function(e) {
              // console.log(e.data.data)
              // console.log("红人+" + e.data.data.total_data.gifts.data)
              var giftsmouth = e.data.data.total_data.giftsmouth.data;


              if (giftsmouth.length > 4) {
                var giftsmouth_r = giftsmouth.slice(-4).slice(0, 1)
                var giftsmouth_l = giftsmouth.slice(0, -4)
                // console.log(giftsmouth_r)
                // console.log(giftsmouth_l)
                var giftsmouth_all = giftsmouth_l + '.' + giftsmouth_r + "万"
                that.setData({
                  giftsmouth_l: giftsmouth_l,
                  giftsmouth_r: giftsmouth_r,
                  giftsmouth_all: giftsmouth_all
                })
                console.log(giftsmouth_all)
              } else {
                that.setData({
                  giftsmouth_all: e.data.data.total_data.giftsmouth.data
                })
              }
              //push合成新数组
              var guilds = e.data.data.guilds;
              var quick_guild = e.data.data.quick_guild;
              var p1_guilds = [];
              p1_guilds.push(...guilds)
              p1_guilds.push(...quick_guild)

              that.setData({
                p1_guilds: p1_guilds,
                p1_total_data: e.data.data.total_data
              })
              if (e.data.data.total_data.income_diamond) {
                var diamond_int = parseInt(e.data.data.total_data.income_diamond.data)
                var diamond_ceil = Math.ceil(diamond_int).toString()
                that.setData({
                  pj_total: diamond_ceil
                })

              } else {
                var gift_int = parseInt(e.data.data.total_data.gifts.data)
                var gift_ceil = Math.ceil(gift_int).toString()
                that.setData({
                  pj_total: gift_ceil
                })
              }
              console.log('int+' + gift_ceil)
              console.log(that.data.pj_total);
              if (that.data.pj_total.length > 4) {

                var gift_pj_1 = that.data.pj_total.slice(-4); //后面四位
                var gift_pj_2 = that.data.pj_total.slice(0, -4) + '.'
                // console.log('显示万')
                if (that.data.pj_total.length >= 9) {
                  that.setData({
                    show_yi: true
                  })
                } else {
                  // console.log('隐藏亿')
                  that.setData({
                    show_yi: false
                  })
                }
                that.setData({
                  show_wan: true,
                  gift_pj_1: gift_pj_1,
                  gift_pj_2: gift_pj_2
                })
              } else {
                // console.log('不到万，走这里')
                // console.log('隐藏万')
                that.setData({
                  show_wan: false,
                  gift_pj_1: '',
                  gift_pj_2: that.data.pj_total
                })
                // console.log(that.data.show_wan)
              }
            }
          });
        } else {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/mainnew',
            data: {
              token: app.globalData.token,
              guild_id: this.data.guild_id,
              start_date: this.data.start_date,
              end_date: this.data.end_date
            },
            success: function(e) {
              // console.log(e.data.data)
              // console.log("红人+" + e.data.data.total_data.gifts.data)
              var giftsmouth = e.data.data.total_data.giftsmouth.data;


              if (giftsmouth.length > 4) {
                var giftsmouth_r = giftsmouth.slice(-4).slice(0, 1)
                var giftsmouth_l = giftsmouth.slice(0, -4)
                // console.log(giftsmouth_r)
                // console.log(giftsmouth_l)
                var giftsmouth_all = giftsmouth_l + '.' + giftsmouth_r + "万"
                that.setData({
                  giftsmouth_l: giftsmouth_l,
                  giftsmouth_r: giftsmouth_r,
                  giftsmouth_all: giftsmouth_all
                })
                console.log(giftsmouth_all)
              } else {
                that.setData({
                  giftsmouth_all: e.data.data.total_data.giftsmouth.data
                })
              }
              //push合成新数组
              var guilds = e.data.data.guilds;
              var quick_guild = e.data.data.quick_guild;
              var p1_guilds = [];
              p1_guilds.push(...guilds)
              p1_guilds.push(...quick_guild)

              that.setData({
                p1_guilds: p1_guilds,
                p1_total_data: e.data.data.total_data
              })
              if (e.data.data.total_data.income_diamond) {
                var diamond_int = parseInt(e.data.data.total_data.income_diamond.data)
                var diamond_ceil = Math.ceil(diamond_int).toString()
                that.setData({
                  pj_total: diamond_ceil
                })

              } else {
                var gift_int = parseInt(e.data.data.total_data.gifts.data)
                var gift_ceil = Math.ceil(gift_int).toString()
                that.setData({
                  pj_total: gift_ceil
                })
              }
              console.log('int+' + gift_ceil)
              console.log(that.data.pj_total);
              if (that.data.pj_total.length > 4) {

                var gift_pj_1 = that.data.pj_total.slice(-4); //后面四位
                var gift_pj_2 = that.data.pj_total.slice(0, -4) + '.'
                // console.log('显示万')
                if (that.data.pj_total.length >= 9) {
                  that.setData({
                    show_yi: true
                  })
                } else {
                  // console.log('隐藏亿')
                  that.setData({
                    show_yi: false
                  })
                }
                that.setData({
                  show_wan: true,
                  gift_pj_1: gift_pj_1,
                  gift_pj_2: gift_pj_2
                })
              } else {
                // console.log('不到万，走这里')
                // console.log('隐藏万')
                that.setData({
                  show_wan: false,
                  gift_pj_1: '',
                  gift_pj_2: that.data.pj_total
                })
                // console.log(that.data.show_wan)
              }
            }
          });
        }

        //排行数据
        if (app.register_info.register_role == 2) {
          if (this.data.table_flag) {
            wx.request({
              method: 'POST',
              url: app.globalData.url + 'api/report/index/topnew',
              data: {
                guild_id: this.data.guild_id,
                token: app.globalData.token,
                start_date: this.data.start_date,
                end_date: this.data.end_date,
                quick: "1",
                table_flag: this.data.table_flag,
              },
              success: function(e) {
                // console.log(e)
                var p1_top_data = e.data.data.anchor_top[that.data.index].data.data;
                var p1_top_name = e.data.data.anchor_top[that.data.index].name;
                var foot_name = e.data.data.anchor_top;
                // console.log(foot_name)
                that.setData({
                  p1_top_data: p1_top_data,
                  p1_top_name: p1_top_name,
                  foot_name: foot_name
                })
                wx.hideLoading()
              }

            })
          } else {
            wx.request({
              method: 'POST',
              url: app.globalData.url + 'api/report/index/topnew',
              data: {
                guild_id: this.data.guild_id,
                token: app.globalData.token,
                start_date: this.data.start_date,
                end_date: this.data.end_date
              },
              success: function(e) {
                console.log(e)
                var p1_top_data = e.data.data.top_data[that.data.index].data.data;
                var p1_top_name = e.data.data.top_data[that.data.index].name;
                var foot_name = e.data.data.top_data;
                // console.log(foot_name)
                that.setData({
                  p1_top_data: p1_top_data,
                  p1_top_name: p1_top_name,
                  foot_name: foot_name
                })
                wx.hideLoading()
              }

            })
          }
        } else {
          if (this.data.table_flag) {
            wx.request({
              method: 'POST',
              url: app.globalData.url + 'api/report/index/topnew',
              data: {
                guild_id: this.data.guild_id,
                token: app.globalData.token,
                start_date: this.data.start_date,
                end_date: this.data.end_date,
                quick: "1",
                table_flag: this.data.table_flag,
              },
              success: function(e) {
                var p1_top_data = e.data.data.top_data[that.data.index].data.data;
                var p1_top_name = e.data.data.top_data[that.data.index].name;
                var foot_name = e.data.data.top_data;
                // console.log(foot_name)
                that.setData({
                  p1_top_data: p1_top_data,
                  p1_top_name: p1_top_name,
                  foot_name: foot_name
                })
                wx.hideLoading()
              }

            })
          } else {
            wx.request({
              method: 'POST',
              url: app.globalData.url + 'api/report/index/topnew',
              data: {
                guild_id: this.data.guild_id,
                token: app.globalData.token,
                start_date: this.data.start_date,
                end_date: this.data.end_date
              },
              success: function(e) {
                var p1_top_data = e.data.data.top_data[that.data.index].data.data;
                var p1_top_name = e.data.data.top_data[that.data.index].name;
                var foot_name = e.data.data.top_data;
                // console.log(foot_name)
                that.setData({
                  p1_top_data: p1_top_data,
                  p1_top_name: p1_top_name,
                  foot_name: foot_name
                })
                wx.hideLoading()
              }

            })
          }

        }
        var date = new Date();
        var nowtime = date.getFullYear() + '/' + ((date.getMonth() + 1) > 10 ? (date.getMonth() + 1) : "0" + (date.getMonth() + 1)) + '/' + (date.getDate() > 10 ? (date.getDate()) : '0' + (date.getDate()))
        var test = Date.parse(nowtime) / 1000
        // if (app.globalData.start_date == test) {
        //   this.setData({
        //     realTime: true
        //   })
        // } else {
        //   this.setData({
        //     realTime: false
        //   })
        // }
      }

      //mark
      var myDate = new Date();
      var panduan = Date.parse(myDate.toLocaleDateString()) / 1000;

      if (panduan <= app.globalData.start_date) {
        this.setData({
          right_color: '#666',
        })
        wx.hideLoading()
        return false;

      } else {
        this.setData({
          right_color: '#fff'
        })
      }
      console.log('111111+' + this.data.gift_pj_1)
      console.log('222222+' + this.data.gift_pj_2)



      //点击结束

    } else if (this.data.btn_r == '后一周') {
      // console.log("点击周")

      var d = new Date();
      var shijian1 = d.getFullYear() + '/' + (d.getMonth() + 1) + '/' + d.getDate()
      var shijian2 = (d.getDay() - 1) * 86400
      var date_ = new Date(shijian1)
      var sjc_ = date_.getTime() / 1000
      var last_sjc = sjc_ - shijian2

      if (app.globalData.start_date < last_sjc) {
        app.globalData.start_date = app.globalData.start_date + 86400 * 7;
        app.globalData.end_date = app.globalData.end_date + 86400 * 7
        //角色编号、日期转换
        this.setData({
          register_role: app.register_info.register_role,

          start_date: app.globalData.start_date,
          end_date: app.globalData.end_date

        })
        if (app.globalData.flag == "day") {
          this.setData({
            start_time: time.formatTimeTwo(app.globalData.start_date, 'Y年M月D日'),
            end_time: time.formatTimeTwo(app.globalData.end_date, 'Y年M月D日')
          })
        }
        if (app.globalData.flag == "week") {
          this.setData({
            start_time: time.formatTimeTwo(app.globalData.start_date, 'M月D日'),
            end_time: time.formatTimeTwo(app.globalData.end_date, 'M月D日')
          })
        }
        if (app.globalData.flag == "other") {
          this.setData({
            start_time: time.formatTimeTwo(app.globalData.start_date, 'M月D日'),
            end_time: time.formatTimeTwo(app.globalData.end_date, 'M月D日')
          })
        }
        if (app.globalData.flag == "month") {
          this.setData({
            start_time: time.formatTimeTwo(app.globalData.start_date, 'Y年M月'),
            end_time: time.formatTimeTwo(app.globalData.end_date, 'Y年M月')
          })
        }

        // console.log(this.data.start_time),
        // console.log(this.data.end_time)


        //  高度自适应

        // if (app.register_info.register_role == 1) {
        //头部数据
        if (this.data.table_flag) {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/mainnew',
            data: {
              token: app.globalData.token,
              guild_id: this.data.guild_id,
              start_date: this.data.start_date,
              end_date: this.data.end_date,
              quick: "1",
              table_flag: this.data.table_flag,
            },
            success: function(e) {
              // console.log(e.data.data)
              var giftsmouth = e.data.data.total_data.giftsmouth.data;


              if (giftsmouth.length > 4) {
                var giftsmouth_r = giftsmouth.slice(-4).slice(0, 1)
                var giftsmouth_l = giftsmouth.slice(0, -4)
                // console.log(giftsmouth_r)
                // console.log(giftsmouth_l)
                var giftsmouth_all = giftsmouth_l + '.' + giftsmouth_r + "万"
                that.setData({
                  giftsmouth_l: giftsmouth_l,
                  giftsmouth_r: giftsmouth_r,
                  giftsmouth_all: giftsmouth_all
                })
                console.log(giftsmouth_all)
              } else {
                that.setData({
                  giftsmouth_all: e.data.data.total_data.giftsmouth.data
                })
              } //万

              //push合成新数组
              var guilds = e.data.data.guilds;
              var quick_guild = e.data.data.quick_guild;
              var p1_guilds = [];
              p1_guilds.push(...guilds)
              p1_guilds.push(...quick_guild)

              that.setData({
                p1_guilds: p1_guilds,
                p1_total_data: e.data.data.total_data
              })
              if (e.data.data.total_data.income_diamond) {
                var diamond_int = parseInt(e.data.data.total_data.income_diamond.data)
                var diamond_ceil = Math.ceil(diamond_int).toString()
                that.setData({
                  pj_total: diamond_ceil
                })

              } else {
                var gift_int = parseInt(e.data.data.total_data.gifts.data)
                var gift_ceil = Math.ceil(gift_int).toString()
                that.setData({
                  pj_total: gift_ceil
                })
              }
              // console.log(that.data.pj_total);
              if (that.data.pj_total.length > 4) {

                var gift_pj_1 = that.data.pj_total.slice(-4); //后面四位
                var gift_pj_2 = that.data.pj_total.slice(0, -4) + '.'
                // console.log('显示万')
                if (that.data.pj_total.length >= 9) {
                  that.setData({
                    show_yi: true
                  })
                } else {
                  // console.log('隐藏亿')
                  that.setData({
                    show_yi: false
                  })
                }
                that.setData({
                  show_wan: true,
                  gift_pj_1: gift_pj_1,
                  gift_pj_2: gift_pj_2
                })
              } else {
                // console.log('不到万，走这里')
                // console.log('隐藏万')
                that.setData({
                  show_wan: false,
                  gift_pj_1: '',
                  gift_pj_2: that.data.pj_total
                })
                // console.log(that.data.show_wan)
              }

            }
          });
        } else {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/mainnew',
            data: {
              token: app.globalData.token,
              guild_id: this.data.guild_id,
              start_date: this.data.start_date,
              end_date: this.data.end_date
            },
            success: function(e) {
              // console.log(e.data.data)
              var giftsmouth = e.data.data.total_data.giftsmouth.data;


              if (giftsmouth.length > 4) {
                var giftsmouth_r = giftsmouth.slice(-4).slice(0, 1)
                var giftsmouth_l = giftsmouth.slice(0, -4)
                // console.log(giftsmouth_r)
                // console.log(giftsmouth_l)
                var giftsmouth_all = giftsmouth_l + '.' + giftsmouth_r + "万"
                that.setData({
                  giftsmouth_l: giftsmouth_l,
                  giftsmouth_r: giftsmouth_r,
                  giftsmouth_all: giftsmouth_all
                })
                console.log(giftsmouth_all)
              } else {
                that.setData({
                  giftsmouth_all: e.data.data.total_data.giftsmouth.data
                })
              } //万

              //push合成新数组
              var guilds = e.data.data.guilds;
              var quick_guild = e.data.data.quick_guild;
              var p1_guilds = [];
              p1_guilds.push(...guilds)
              p1_guilds.push(...quick_guild)

              that.setData({
                p1_guilds: p1_guilds,
                p1_total_data: e.data.data.total_data
              })
              if (e.data.data.total_data.income_diamond) {
                var diamond_int = parseInt(e.data.data.total_data.income_diamond.data)
                var diamond_ceil = Math.ceil(diamond_int).toString()
                that.setData({
                  pj_total: diamond_ceil
                })

              } else {
                var gift_int = parseInt(e.data.data.total_data.gifts.data)
                var gift_ceil = Math.ceil(gift_int).toString()
                that.setData({
                  pj_total: gift_ceil
                })
              }
              // console.log(that.data.pj_total);
              if (that.data.pj_total.length > 4) {

                var gift_pj_1 = that.data.pj_total.slice(-4); //后面四位
                var gift_pj_2 = that.data.pj_total.slice(0, -4) + '.'
                // console.log('显示万')
                if (that.data.pj_total.length >= 9) {
                  that.setData({
                    show_yi: true
                  })
                } else {
                  // console.log('隐藏亿')
                  that.setData({
                    show_yi: false
                  })
                }
                that.setData({
                  show_wan: true,
                  gift_pj_1: gift_pj_1,
                  gift_pj_2: gift_pj_2
                })
              } else {
                // console.log('不到万，走这里')
                // console.log('隐藏万')
                that.setData({
                  show_wan: false,
                  gift_pj_1: '',
                  gift_pj_2: that.data.pj_total
                })
                // console.log(that.data.show_wan)
              }

            }
          });
        }

        //排行数据
        if (app.register_info.register_role == 2) {
          if (this.data.table_flag) {
            wx.request({
              method: 'POST',
              url: app.globalData.url + 'api/report/index/topnew',
              data: {
                guild_id: this.data.guild_id,
                token: app.globalData.token,
                start_date: this.data.start_date,
                end_date: this.data.end_date,
                quick: "1",
                table_flag: this.data.table_flag,
              },
              success: function(e) {
                // console.log(e)
                var p1_top_data = e.data.data.anchor_top[that.data.index].data.data;
                var p1_top_name = e.data.data.anchor_top[that.data.index].name;
                var foot_name = e.data.data.anchor_top;
                // console.log(foot_name)
                that.setData({
                  p1_top_data: p1_top_data,
                  p1_top_name: p1_top_name,
                  foot_name: foot_name
                })
                wx.hideLoading()
              }

            })
          } else {
            wx.request({
              method: 'POST',
              url: app.globalData.url + 'api/report/index/topnew',
              data: {
                guild_id: this.data.guild_id,
                token: app.globalData.token,
                start_date: this.data.start_date,
                end_date: this.data.end_date
              },
              success: function(e) {
                console.log(e)
                var p1_top_data = e.data.data.top_data[that.data.index].data.data;
                var p1_top_name = e.data.data.top_data[that.data.index].name;
                var foot_name = e.data.data.top_data;
                // console.log(foot_name)
                that.setData({
                  p1_top_data: p1_top_data,
                  p1_top_name: p1_top_name,
                  foot_name: foot_name
                })
                wx.hideLoading()
              }

            })
          }
        } else {
          if (this.data.table_flag) {
            wx.request({
              method: 'POST',
              url: app.globalData.url + 'api/report/index/topnew',
              data: {
                guild_id: this.data.guild_id,
                token: app.globalData.token,
                start_date: this.data.start_date,
                end_date: this.data.end_date,
                quick: "1",
                table_flag: this.data.table_flag,
              },
              success: function(e) {
                var p1_top_data = e.data.data.top_data[that.data.index].data.data;
                var p1_top_name = e.data.data.top_data[that.data.index].name;
                var foot_name = e.data.data.top_data;
                // console.log(foot_name)
                that.setData({
                  p1_top_data: p1_top_data,
                  p1_top_name: p1_top_name,
                  foot_name: foot_name
                })
                wx.hideLoading()
              }

            })
          } else {
            wx.request({
              method: 'POST',
              url: app.globalData.url + 'api/report/index/topnew',
              data: {
                guild_id: this.data.guild_id,
                token: app.globalData.token,
                start_date: this.data.start_date,
                end_date: this.data.end_date
              },
              success: function(e) {
                var p1_top_data = e.data.data.top_data[that.data.index].data.data;
                var p1_top_name = e.data.data.top_data[that.data.index].name;
                var foot_name = e.data.data.top_data;
                // console.log(foot_name)
                that.setData({
                  p1_top_data: p1_top_data,
                  p1_top_name: p1_top_name,
                  foot_name: foot_name
                })
                wx.hideLoading()
              }

            })
          }

        }
      } else {
        that.setData({
          right_color: '#666'
        })
        wx.hideLoading()
        return false;
      }




    } else if (this.data.btn_r == '后一月') {
      console.log("点击月");
      var get_month = this.data.start_time.slice(5, 7);
      var get_year = this.data.start_time.split("年")[0]
      //判断字体颜色
      var date = new Date();
      var panduanyue = Date.parse(date.getFullYear() + '/' + (date.getMonth() + 1) + '/1') / 1000;
      console.log(this.data.start_time)
      console.log('33333311' + get_month)
      console.log('33333322' + get_year)
      if (panduanyue <= app.globalData.start_date) {

        this.setData({
          right_color: '#666',
        })
        wx.hideLoading()
        return false;
      } else {
        this.setData({
          right_color: '#fff',
        })
        // console.log(get_year)
        switch (get_month) {
          case "01":
            if ((get_year % 4 == 0) && (get_year % 100 != 0 || get_year % 400 == 0)) {
              //闰年
              app.globalData.start_date = app.globalData.start_date + 86400 * 31;
              app.globalData.end_date = app.globalData.end_date + 86400 * 29;
              // console.log(app.globalData.start_date);
              break;
            } else {
              //平年
              app.globalData.start_date = app.globalData.start_date + 86400 * 31;
              app.globalData.end_date = app.globalData.end_date + 86400 * 28;
              // console.log(app.globalData.start_date);
              break;
            }

            // console.log(app.globalData.start_date);
            break;
          case "02":
            if ((get_year % 4 == 0) && (get_year % 100 != 0 || get_year % 400 == 0)) {
              //闰年
              app.globalData.start_date = app.globalData.start_date + 86400 * 29;
              app.globalData.end_date = app.globalData.end_date + 86400 * 31;
              // console.log(app.globalData.start_date);
              break;
            } else {
              //平年
              app.globalData.start_date = app.globalData.start_date + 86400 * 28;
              app.globalData.end_date = app.globalData.end_date + 86400 * 31;
              // console.log(app.globalData.start_date);
              break;
            }

          case "03":
            app.globalData.start_date = app.globalData.start_date + 86400 * 31;
            app.globalData.end_date = app.globalData.end_date + 86400 * 30;
            // console.log(app.globalData.start_date);
            break;
          case "04":
            app.globalData.start_date = app.globalData.start_date + 86400 * 30;
            app.globalData.end_date = app.globalData.end_date + 86400 * 31;
            // console.log(app.globalData.start_date);
            break;
          case "05":
            app.globalData.start_date = app.globalData.start_date + 86400 * 31;
            app.globalData.end_date = app.globalData.end_date + 86400 * 30;
            // console.log(app.globalData.start_date);
            break;
          case "06":
            app.globalData.start_date = app.globalData.start_date + 86400 * 30;
            app.globalData.end_date = app.globalData.end_date + 86400 * 31;
            // console.log(app.globalData.start_date);
            break;
          case "07":
            app.globalData.start_date = app.globalData.start_date + 86400 * 31;
            app.globalData.end_date = app.globalData.end_date + 86400 * 31;
            // console.log(app.globalData.start_date);
            break;
          case "08":
            app.globalData.start_date = app.globalData.start_date + 86400 * 31;
            app.globalData.end_date = app.globalData.end_date + 86400 * 30;
            // console.log(app.globalData.start_date);
            break;
          case "09":
            app.globalData.start_date = app.globalData.start_date + 86400 * 30;
            app.globalData.end_date = app.globalData.end_date + 86400 * 31;
            // console.log(app.globalData.start_date);
            break;
          case "10":
            app.globalData.start_date = app.globalData.start_date + 86400 * 31;
            app.globalData.end_date = app.globalData.end_date + 86400 * 30;
            // console.log(app.globalData.start_date);
            break;
          case "11":
            app.globalData.start_date = app.globalData.start_date + 86400 * 30;
            app.globalData.end_date = app.globalData.end_date + 86400 * 31;
            // console.log(app.globalData.start_date);
            break;
          case "12":
            app.globalData.start_date = app.globalData.start_date + 86400 * 31;
            app.globalData.end_date = app.globalData.end_date + 86400 * 31;
            // console.log(app.globalData.start_date);
            break;
        }

        //点击开始

        //角色编号、日期转换
        this.setData({
          register_role: app.register_info.register_role,

          start_date: app.globalData.start_date,
          end_date: app.globalData.end_date


        })
        if (app.globalData.flag == "day") {
          this.setData({
            start_time: time.formatTimeTwo(app.globalData.start_date, 'Y年M月D日'),
            end_time: time.formatTimeTwo(app.globalData.end_date, 'Y年M月D日')
          })
        }
        if (app.globalData.flag == "week") {
          this.setData({
            start_time: time.formatTimeTwo(app.globalData.start_date, 'M月D日'),
            end_time: time.formatTimeTwo(app.globalData.end_date, 'M月D日')
          })
        }
        if (app.globalData.flag == "other") {
          this.setData({
            start_time: time.formatTimeTwo(app.globalData.start_date, 'M月D日'),
            end_time: time.formatTimeTwo(app.globalData.end_date, 'M月D日')
          })
        }
        if (app.globalData.flag == "month") {
          this.setData({
            start_time: time.formatTimeTwo(app.globalData.start_date, 'Y年M月'),
            end_time: time.formatTimeTwo(app.globalData.end_date, 'Y年M月')
          })
        }
        console.log(this.data.start_time),
          console.log(this.data.end_time)


        //  高度自适应


        // if (app.register_info.register_role == 1) {
        //头部数据
        if (this.data.table_flag) {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/mainnew',
            data: {
              token: app.globalData.token,
              guild_id: this.data.guild_id,
              start_date: this.data.start_date,
              end_date: this.data.end_date,
              quick: "1",
              table_flag: this.data.table_flag,
            },
            success: function(e) {
              console.log(e.data.data)
              var giftsmouth = e.data.data.total_data.giftsmouth.data;


              if (giftsmouth.length > 4) {
                var giftsmouth_r = giftsmouth.slice(-4).slice(0, 1)
                var giftsmouth_l = giftsmouth.slice(0, -4)
                // console.log(giftsmouth_r)
                // console.log(giftsmouth_l)
                var giftsmouth_all = giftsmouth_l + '.' + giftsmouth_r + "万"
                that.setData({
                  giftsmouth_l: giftsmouth_l,
                  giftsmouth_r: giftsmouth_r,
                  giftsmouth_all: giftsmouth_all
                })
                console.log(giftsmouth_all)
              } else {
                that.setData({
                  giftsmouth_all: e.data.data.total_data.giftsmouth.data
                })
              }

              //push合成新数组
              var guilds = e.data.data.guilds;
              var quick_guild = e.data.data.quick_guild;
              var p1_guilds = [];
              p1_guilds.push(...guilds)
              p1_guilds.push(...quick_guild)

              that.setData({
                p1_guilds: p1_guilds,
                p1_total_data: e.data.data.total_data
              })
              if (e.data.data.total_data.income_diamond) {
                var diamond_int = parseInt(e.data.data.total_data.income_diamond.data)
                var diamond_ceil = Math.ceil(diamond_int).toString()
                that.setData({
                  pj_total: diamond_ceil
                })

              } else {
                var gift_int = parseInt(e.data.data.total_data.gifts.data)
                var gift_ceil = Math.ceil(gift_int).toString()
                that.setData({
                  pj_total: gift_ceil
                })
              }
              // console.log(that.data.pj_total);
              if (that.data.pj_total.length > 4) {

                var gift_pj_1 = that.data.pj_total.slice(-4); //后面四位
                var gift_pj_2 = that.data.pj_total.slice(0, -4) + '.'
                // console.log('显示万')
                if (that.data.pj_total.length >= 9) {
                  that.setData({
                    show_yi: true
                  })
                } else {
                  // console.log('隐藏亿')
                  that.setData({
                    show_yi: false
                  })
                }
                that.setData({
                  show_wan: true,
                  gift_pj_1: gift_pj_1,
                  gift_pj_2: gift_pj_2
                })
              } else {
                // console.log('不到万，走这里')
                // console.log('隐藏万')
                that.setData({
                  show_wan: false,
                  gift_pj_1: '',
                  gift_pj_2: that.data.pj_total
                })
                // console.log(that.data.show_wan)
              }
            }
          });
        } else {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/mainnew',
            data: {
              token: app.globalData.token,
              guild_id: this.data.guild_id,
              start_date: this.data.start_date,
              end_date: this.data.end_date
            },
            success: function(e) {
              console.log(e.data.data)
              var giftsmouth = e.data.data.total_data.giftsmouth.data;


              if (giftsmouth.length > 4) {
                var giftsmouth_r = giftsmouth.slice(-4).slice(0, 1)
                var giftsmouth_l = giftsmouth.slice(0, -4)
                // console.log(giftsmouth_r)
                // console.log(giftsmouth_l)
                var giftsmouth_all = giftsmouth_l + '.' + giftsmouth_r + "万"
                that.setData({
                  giftsmouth_l: giftsmouth_l,
                  giftsmouth_r: giftsmouth_r,
                  giftsmouth_all: giftsmouth_all
                })
                console.log(giftsmouth_all)
              } else {
                that.setData({
                  giftsmouth_all: e.data.data.total_data.giftsmouth.data
                })
              }

              //push合成新数组
              var guilds = e.data.data.guilds;
              var quick_guild = e.data.data.quick_guild;
              var p1_guilds = [];
              p1_guilds.push(...guilds)
              p1_guilds.push(...quick_guild)

              that.setData({
                p1_guilds: p1_guilds,
                p1_total_data: e.data.data.total_data
              })
              if (e.data.data.total_data.income_diamond) {
                var diamond_int = parseInt(e.data.data.total_data.income_diamond.data)
                var diamond_ceil = Math.ceil(diamond_int).toString()
                that.setData({
                  pj_total: diamond_ceil
                })

              } else {
                var gift_int = parseInt(e.data.data.total_data.gifts.data)
                var gift_ceil = Math.ceil(gift_int).toString()
                that.setData({
                  pj_total: gift_ceil
                })
              }
              // console.log(that.data.pj_total);
              if (that.data.pj_total.length > 4) {

                var gift_pj_1 = that.data.pj_total.slice(-4); //后面四位
                var gift_pj_2 = that.data.pj_total.slice(0, -4) + '.'
                // console.log('显示万')
                if (that.data.pj_total.length >= 9) {
                  that.setData({
                    show_yi: true
                  })
                } else {
                  // console.log('隐藏亿')
                  that.setData({
                    show_yi: false
                  })
                }
                that.setData({
                  show_wan: true,
                  gift_pj_1: gift_pj_1,
                  gift_pj_2: gift_pj_2
                })
              } else {
                // console.log('不到万，走这里')
                // console.log('隐藏万')
                that.setData({
                  show_wan: false,
                  gift_pj_1: '',
                  gift_pj_2: that.data.pj_total
                })
                // console.log(that.data.show_wan)
              }
            }
          });
        }

        //排行数据
        if (app.register_info.register_role == 2) {
          if (this.data.table_flag) {
            wx.request({
              method: 'POST',
              url: app.globalData.url + 'api/report/index/topnew',
              data: {
                guild_id: this.data.guild_id,
                token: app.globalData.token,
                start_date: this.data.start_date,
                end_date: this.data.end_date,
                quick: "1",
                table_flag: this.data.table_flag,
              },
              success: function(e) {
                // console.log(e)
                var p1_top_data = e.data.data.anchor_top[that.data.index].data.data;
                var p1_top_name = e.data.data.anchor_top[that.data.index].name;
                var foot_name = e.data.data.anchor_top;
                // console.log(foot_name)
                that.setData({
                  p1_top_data: p1_top_data,
                  p1_top_name: p1_top_name,
                  foot_name: foot_name
                })
                wx.hideLoading()
              }

            })
          } else {
            wx.request({
              method: 'POST',
              url: app.globalData.url + 'api/report/index/topnew',
              data: {
                guild_id: this.data.guild_id,
                token: app.globalData.token,
                start_date: this.data.start_date,
                end_date: this.data.end_date
              },
              success: function(e) {
                console.log(e)
                var p1_top_data = e.data.data.top_data[that.data.index].data.data;
                var p1_top_name = e.data.data.top_data[that.data.index].name;
                var foot_name = e.data.data.top_data;
                // console.log(foot_name)
                that.setData({
                  p1_top_data: p1_top_data,
                  p1_top_name: p1_top_name,
                  foot_name: foot_name
                })
                wx.hideLoading()
              }

            })
          }
        } else {
          if (this.data.table_flag) {
            wx.request({
              method: 'POST',
              url: app.globalData.url + 'api/report/index/topnew',
              data: {
                guild_id: this.data.guild_id,
                token: app.globalData.token,
                start_date: this.data.start_date,
                end_date: this.data.end_date,
                table_flag: this.data.table_flag,
                quick: "1",
              },
              success: function(e) {
                var p1_top_data = e.data.data.top_data[that.data.index].data.data;
                var p1_top_name = e.data.data.top_data[that.data.index].name;
                var foot_name = e.data.data.top_data;
                // console.log(foot_name)
                that.setData({
                  p1_top_data: p1_top_data,
                  p1_top_name: p1_top_name,
                  foot_name: foot_name
                })
                wx.hideLoading()
              }

            })
          } else {
            wx.request({
              method: 'POST',
              url: app.globalData.url + 'api/report/index/topnew',
              data: {
                guild_id: this.data.guild_id,
                token: app.globalData.token,
                start_date: this.data.start_date,
                end_date: this.data.end_date
              },
              success: function(e) {
                var p1_top_data = e.data.data.top_data[that.data.index].data.data;
                var p1_top_name = e.data.data.top_data[that.data.index].name;
                var foot_name = e.data.data.top_data;
                // console.log(foot_name)
                that.setData({
                  p1_top_data: p1_top_data,
                  p1_top_name: p1_top_name,
                  foot_name: foot_name
                })
                wx.hideLoading()
              }

            })
          }

        }
      }



      //点击结束
      var date = new Date();
      var nowtime = date.getFullYear() + '/' + ((date.getMonth() + 1) > 10 ? (date.getMonth() + 1) : "0" + (date.getMonth() + 1)) + '/' + (date.getDate() > 10 ? (date.getDate()) : '0' + (date.getDate()))
      var test = Date.parse(nowtime) / 1000
      if (this.data.start_date == test) {
        console.log("今日")
      }

    }

  },


  //禁止滑动
  catchTouchMove: function(res) {
    return false
  },
  //底部点击切换
  s_b_Nav: function(e) {
    this.setData({
      index: '0',
    })
    // this.setData({
    //   p1_top_data: '',
    //   p1_top_name: '',
    //   foot_name: '',
    // })
    wx.showLoading({
      title: '小主稍等~',
    })
    setTimeout(function() {
      wx.hideLoading()
    }, 5000)
    var that = this;
    var cur = e.target.dataset.current;
    if (that.data.current_b_Tab == cur) {
      return false;
    } else {
      that.setData({
        current_b_Tab: cur,
        index: cur
      })
      //获取排行榜数据
      if (app.register_info.register_role == 2) {
        if (this.data.table_flag) {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/topnew',
            data: {
              guild_id: this.data.guild_id,
              token: app.globalData.token,
              start_date: this.data.start_date,
              end_date: this.data.end_date,
              quick: "1",
              table_flag: this.data.table_flag,
            },
            success: function(e) {
              // console.log(e)
              var p1_top_data = e.data.data.anchor_top[that.data.index].data.data;
              var p1_top_name = e.data.data.anchor_top[that.data.index].name;
              var foot_name = e.data.data.anchor_top;
              // console.log(foot_name)
              that.setData({
                p1_top_data: p1_top_data,
                p1_top_name: p1_top_name,
                foot_name: foot_name
              })
              wx.hideLoading()
            }

          })
        } else {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/topnew',
            data: {
              guild_id: this.data.guild_id,
              token: app.globalData.token,
              start_date: this.data.start_date,
              end_date: this.data.end_date
            },
            success: function(e) {
              console.log(e)
              var p1_top_data = e.data.data.top_data[that.data.index].data.data;
              var p1_top_name = e.data.data.top_data[that.data.index].name;
              var foot_name = e.data.data.top_data;
              // console.log(foot_name)
              that.setData({
                p1_top_data: p1_top_data,
                p1_top_name: p1_top_name,
                foot_name: foot_name
              })
              wx.hideLoading()
            }

          })
        }
      } else {
        if (this.data.table_flag) {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/topnew',
            data: {
              guild_id: this.data.guild_id,
              token: app.globalData.token,
              start_date: this.data.start_date,
              end_date: this.data.end_date,
              quick: "1",
              table_flag: that.data.table_flag,
            },
            success: function(e) {
              var p1_top_data = e.data.data.top_data[that.data.index].data.data;
              var p1_top_name = e.data.data.top_data[that.data.index].name;
              var foot_name = e.data.data.top_data;
              // console.log(foot_name)
              that.setData({
                p1_top_data: p1_top_data,
                p1_top_name: p1_top_name,
                foot_name: foot_name
              })
              wx.hideLoading()
            }

          })
        } else {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/topnew',
            data: {
              guild_id: this.data.guild_id,
              token: app.globalData.token,
              start_date: this.data.start_date,
              end_date: this.data.end_date,

            },
            success: function(e) {
              var p1_top_data = e.data.data.top_data[that.data.index].data.data;
              var p1_top_name = e.data.data.top_data[that.data.index].name;
              var foot_name = e.data.data.top_data;
              // console.log(foot_name)
              that.setData({
                p1_top_data: p1_top_data,
                p1_top_name: p1_top_name,
                foot_name: foot_name
              })
              wx.hideLoading()
            }

          })
        }

      }
    }

  },
  //选择日期/flag
  select_time: function() {
    // app.globalData.flag
    wx.navigateTo({
      url: '../selectTime/selectTime',
    })
  },



  // 滚动切换标签样式
  switchTab: function(e) {
    wx.showLoading({
      title: '小主稍等~'
    })
    // console.log(e)
    var that = this;
    this.setData({
      currentTab: e.detail.current,
      gift_pj_1: '',
      gift_pj_2: '',
      pj_total: ''
    });
    this.checkCor();
    //判断 切换的个
    var guild_id = this.data.p1_guilds[this.data.currentTab].guild_id

    console.log('guild_id+' + guild_id)

    this.setData({
      guild_id: guild_id
    })
    //头部数据
    if (this.data.table_flag) {
      //快速公会
      wx.request({
        method: 'POST',
        url: app.globalData.url + 'api/report/index/mainnew',
        data: {
          token: app.globalData.token,
          guild_id: this.data.guild_id,
          start_date: this.data.start_date,
          end_date: this.data.end_date,
          quick: "1",
          table_flag: this.data.table_flag,
        },
        success: function(e) {
          // console.log(e.data.code)

          // console.log(e.data.data.total_data)
          var giftsmouth = e.data.data.total_data.giftsmouth.data;


          if (giftsmouth.length > 4) {
            var giftsmouth_r = giftsmouth.slice(-4).slice(0, 1)
            var giftsmouth_l = giftsmouth.slice(0, -4)
            // console.log(giftsmouth_r)
            // console.log(giftsmouth_l)
            var giftsmouth_all = giftsmouth_l + '.' + giftsmouth_r + "万"
            that.setData({
              giftsmouth_l: giftsmouth_l,
              giftsmouth_r: giftsmouth_r,
              giftsmouth_all: giftsmouth_all
            })
            console.log(giftsmouth_all)
          } else {
            that.setData({
              giftsmouth_all: e.data.data.total_data.giftsmouth.data
            })
          }

          //push合成新数组
          var guilds = e.data.data.guilds;
          var quick_guild = e.data.data.quick_guild;
          var p1_guilds = [];
          p1_guilds.push(...guilds)
          p1_guilds.push(...quick_guild)

          that.setData({
            p1_guilds: p1_guilds,
            p1_total_data: e.data.data.total_data,
            p1_giftsmouth: e.data.data.total_data.giftsmouth
          })
          if (e.data.data.total_data.income_diamond) {
            var diamond_int = parseInt(e.data.data.total_data.income_diamond.data)
            var diamond_ceil = Math.ceil(diamond_int).toString()
            that.setData({
              pj_total: diamond_ceil
            })

          } else {
            var gift_int = parseInt(e.data.data.total_data.gifts.data)
            var gift_ceil = Math.ceil(gift_int).toString()
            that.setData({
              pj_total: gift_ceil
            })
          }
          // console.log(that.data.pj_total);
          if (that.data.pj_total.length > 4) {

            var gift_pj_1 = that.data.pj_total.slice(-4); //后面四位
            var gift_pj_2 = that.data.pj_total.slice(0, -4) + '.'
            // console.log('显示万')
            if (that.data.pj_total.length >= 9) {
              that.setData({
                show_yi: true
              })
            } else {
              // console.log('隐藏亿')
              that.setData({
                show_yi: false
              })
            }
            that.setData({
              show_wan: true,
              gift_pj_1: gift_pj_1,
              gift_pj_2: gift_pj_2
            })
          } else {
            // console.log('不到万，走这里')
            // console.log('隐藏万')
            that.setData({
              show_wan: false,
              gift_pj_1: '',
              gift_pj_2: that.data.pj_total
            })
            // console.log(that.data.show_wan)
          }
        }
      });
    } else {
      //普通公会
      wx.request({
        method: 'POST',
        url: app.globalData.url + 'api/report/index/mainnew',
        data: {
          token: app.globalData.token,
          guild_id: this.data.guild_id,
          start_date: this.data.start_date,
          end_date: this.data.end_date,

        },
        success: function(e) {
          console.log(e)
          // console.log(e.data.data.total_data)
          var giftsmouth = e.data.data.total_data.giftsmouth.data;


          if (giftsmouth.length > 4) {
            var giftsmouth_r = giftsmouth.slice(-4).slice(0, 1)
            var giftsmouth_l = giftsmouth.slice(0, -4)
            // console.log(giftsmouth_r)
            // console.log(giftsmouth_l)
            var giftsmouth_all = giftsmouth_l + '.' + giftsmouth_r + "万"
            that.setData({
              giftsmouth_l: giftsmouth_l,
              giftsmouth_r: giftsmouth_r,
              giftsmouth_all: giftsmouth_all
            })
            console.log(giftsmouth_all)
          } else {
            that.setData({
              giftsmouth_all: e.data.data.total_data.giftsmouth.data
            })
          }

          //push合成新数组
          var guilds = e.data.data.guilds;
          var quick_guild = e.data.data.quick_guild;
          var p1_guilds = [];
          p1_guilds.push(...guilds)
          p1_guilds.push(...quick_guild)

          that.setData({
            p1_guilds: p1_guilds,
            p1_total_data: e.data.data.total_data,
            p1_giftsmouth: e.data.data.total_data.giftsmouth
          })
          if (e.data.data.total_data.income_diamond) {
            var diamond_int = parseInt(e.data.data.total_data.income_diamond.data)
            var diamond_ceil = Math.ceil(diamond_int).toString()
            that.setData({
              pj_total: diamond_ceil
            })

          } else {
            var gift_int = parseInt(e.data.data.total_data.gifts.data)
            var gift_ceil = Math.ceil(gift_int).toString()
            that.setData({
              pj_total: gift_ceil
            })
          }
          // console.log(that.data.pj_total);
          if (that.data.pj_total.length > 4) {

            var gift_pj_1 = that.data.pj_total.slice(-4); //后面四位
            var gift_pj_2 = that.data.pj_total.slice(0, -4) + '.'
            // console.log('显示万')
            if (that.data.pj_total.length >= 9) {
              that.setData({
                show_yi: true
              })
            } else {
              // console.log('隐藏亿')
              that.setData({
                show_yi: false
              })
            }
            that.setData({
              show_wan: true,
              gift_pj_1: gift_pj_1,
              gift_pj_2: gift_pj_2
            })
          } else {
            // console.log('不到万，走这里')
            // console.log('隐藏万')
            that.setData({
              show_wan: false,
              gift_pj_1: '',
              gift_pj_2: that.data.pj_total
            })
            // console.log(that.data.show_wan)
          }
        }
      });
    }





    //排行数据
    if (app.register_info.register_role == 2) {
      if (this.data.table_flag) {
        wx.request({
          method: 'POST',
          url: app.globalData.url + 'api/report/index/topnew',
          data: {
            guild_id: this.data.guild_id,
            token: app.globalData.token,
            start_date: this.data.start_date,
            end_date: this.data.end_date,
            quick: "1",
            table_flag: this.data.table_flag,
          },
          success: function(e) {
            console.log(e)
            var p1_top_data = e.data.data.anchor_top[that.data.index].data.data;
            var p1_top_name = e.data.data.anchor_top[that.data.index].name;
            var foot_name = e.data.data.anchor_top;
            // console.log(foot_name)
            // console.log(p1_top_data)
            that.setData({
              p1_top_data: p1_top_data,
              p1_top_name: p1_top_name,
              foot_name: foot_name
            })
            wx.hideLoading()
          }

        })
      } else {
        wx.request({
          method: 'POST',
          url: app.globalData.url + 'api/report/index/topnew',
          data: {
            guild_id: this.data.guild_id,
            token: app.globalData.token,
            start_date: this.data.start_date,
            end_date: this.data.end_date
          },
          success: function(e) {
            console.log(e)
            var p1_top_data = e.data.data.top_data[that.data.index].data.data;
            var p1_top_name = e.data.data.top_data[that.data.index].name;
            var foot_name = e.data.data.top_data;
            // console.log(foot_name)
            that.setData({
              p1_top_data: p1_top_data,
              p1_top_name: p1_top_name,
              foot_name: foot_name
            })
            wx.hideLoading()
          }

        })
      }
    } else {
      if (this.data.table_flag) {
        wx.request({
          method: 'POST',
          url: app.globalData.url + 'api/report/index/topnew',
          data: {
            guild_id: this.data.guild_id,
            token: app.globalData.token,
            start_date: this.data.start_date,
            end_date: this.data.end_date,
            quick: "1",
            table_flag: this.data.table_flag,
          },
          success: function(e) {
            var p1_top_data = e.data.data.top_data[that.data.index].data.data;
            var p1_top_name = e.data.data.top_data[that.data.index].name;
            var foot_name = e.data.data.top_data;
            // console.log(foot_name)
            that.setData({
              p1_top_data: p1_top_data,
              p1_top_name: p1_top_name,
              foot_name: foot_name
            })
            wx.hideLoading()
          }

        })
      } else {
        wx.request({
          method: 'POST',
          url: app.globalData.url + 'api/report/index/topnew',
          data: {
            guild_id: this.data.guild_id,
            token: app.globalData.token,
            start_date: this.data.start_date,
            end_date: this.data.end_date
          },
          success: function(e) {
            var p1_top_data = e.data.data.top_data[that.data.index].data.data;
            var p1_top_name = e.data.data.top_data[that.data.index].name;
            var foot_name = e.data.data.top_data;
            // console.log(foot_name)
            that.setData({
              p1_top_data: p1_top_data,
              p1_top_name: p1_top_name,
              foot_name: foot_name
            })
            wx.hideLoading()
          }

        })
      }

    }

  },
  // 点击标题切换当前页时改变样式
  swichNav: function(e) {
    // console.log(this.data.p1_guilds)
    console.log(e)
    this.setData({
      guild_id: e.currentTarget.dataset.guild_id,
      guild_name: e.currentTarget.dataset.guild_name,
      table_flag: null,
      index: '0',
      current_b_Tab: '0',
    })
    // console.log(e.currentTarget.dataset)
    var cur = e.target.dataset.current;
    var table_flag = e.currentTarget.dataset.table_flag;
    var status = e.currentTarget.dataset.status;
    var head_guild_name = e.currentTarget.dataset.guild_name;
    var head_guild_id = e.currentTarget.dataset.guild_id;
    if (this.data.currentTaB == cur) {
      return false;
    } else {
      this.setData({
        currentTab: cur,
        table_flag: table_flag,
        status: status,
        head_guild_name: head_guild_name,
        head_guild_id: head_guild_id,
      })
    }
    // console.log(this.data.head_guild_name)
    var timer = setTimeout(function() {
      wx.hideLoading();
      clearTimeout(timer)
    }, 3000)
  },
  //判断当前滚动超过一屏时，设置tab标题滚动条。
  checkCor: function() {

  },
  onLoad: function() {
    // if (this.data.p1_top_data == "" || this.data.total_data==""){
    //   console.log("kong")
    //   this.setData({
    //     kong: true,
    //   })
    // }
  },
  onReady: function() {

  },

  onShow: function() {
    wx.request({
      url: app.globalData.url + 'api/mine/guild',
      data: {
        token: app.globalData.token,
      },
      method: 'POST',
      success: (e) => {
        console.log(e);
        let guilds = e.data.data.guilds;
        if (guilds == "") {
          this.setData({
            guild_id: e.data.data.quick_gulid[0].guild_id
          })
        } else {
          this.setData({
            guild_id: e.data.data.guilds[0].guild_id
          })
        }
      },
    })

    this.setData({
      realTime: app.globalData.realTime,
    })


    setTimeout(function() {
      wx.hideLoading()
    }, 3000)

    //授权检测
    if (!(wx.getStorageSync('token'))) {
      wx.redirectTo({
        url: '../author/author',
      })
      // console.log('跳转')
    } else {
      if (wx.getStorageSync('reg_register_role') == '0') {
        wx.showModal({
          content: '选择角色后才能看详情哦~',
          showCancel: false,
          cancelColor: '#333',
          confirmText: '好的',
          confirmColor: '#d0a76c',
          success: function(e) {
            if (e.confirm) {
              wx.redirectTo({
                url: '../../selectIdentity/selectIdentity',
              })
            }
          },
        })
      } else {}
    }



    //日
    var that = this;
    var myDate = new Date();
    var panduan = Date.parse(myDate.toLocaleDateString()) / 1000;
    if (app.globalData.start_date >= panduan) {
      // console.log('2222222' + panduan)
      // console.log('2222222' + app.globalData.start_date)
      this.setData({
        right_color: '#666',
      })

    } else {
      this.setData({
        right_color: '#fff'
      })
    }
    //月
    wx.showLoading({
      title: '小主稍等~',
    })

    switch (app.globalData.flag) {
      case "day":
        this.setData({
          show_time: "日数据",
          btn_l: "前一天",
          btn_r: "后一天",
          btn_show: true
        })
        break;
      case "week":
        this.setData({
          show_time: "周数据",
          btn_l: "前一周",
          btn_r: "后一周",
          btn_show: true
        })
        break;
      case "month":
        this.setData({
          show_time: "月数据",
          btn_l: "前一月",
          btn_r: "后一月",
          btn_show: true
        })
        break;
      case "other":
        this.setData({
          show_time: "自定义",
          btn_show: false
        })
        break;
    }




    //角色编号、日期转换
    this.setData({
      register_role: app.register_info.register_role,

      start_date: app.globalData.start_date,
      end_date: app.globalData.end_date,
    })
    if (app.globalData.flag == "day") {
      this.setData({
        start_time: time.formatTimeTwo(app.globalData.start_date, 'Y年M月D日'),
        end_time: time.formatTimeTwo(app.globalData.end_date, 'Y年M月D日')
      })
    }
    if (app.globalData.flag == "week") {
      this.setData({
        start_time: time.formatTimeTwo(app.globalData.start_date, 'M月D日'),
        end_time: time.formatTimeTwo(app.globalData.end_date, 'M月D日')
      })
    }
    if (app.globalData.flag == "other") {
      this.setData({
        start_time: time.formatTimeTwo(app.globalData.start_date, 'M月D日'),
        end_time: time.formatTimeTwo(app.globalData.end_date, 'M月D日')
      })
    }
    if (app.globalData.flag == "month") {
      this.setData({
        start_time: time.formatTimeTwo(app.globalData.start_date, 'Y年M月'),
        end_time: time.formatTimeTwo(app.globalData.end_date, 'Y年M月')
      })
    }

    // console.log(this.data.start_time),
    // console.log(this.data.end_time)


    //  高度自适应


    // if (app.register_info.register_role == 1) {
    //头部数据
    if (this.data.table_flag) {
      wx.request({
        method: 'POST',
        url: app.globalData.url + 'api/report/index/mainnew',
        data: {
          token: app.globalData.token,
          guild_id: this.data.guild_id,
          start_date: this.data.start_date,
          end_date: this.data.end_date,
          quick: "1",
          table_flag: this.data.table_flag,
        },
        success: function(e) {
          console.log(e)
          var giftsmouth = e.data.data.total_data.giftsmouth.data;


          if (giftsmouth.length > 4) {
            var giftsmouth_r = giftsmouth.slice(-4).slice(0, 1)
            var giftsmouth_l = giftsmouth.slice(0, -4)
            // console.log(giftsmouth_r)
            // console.log(giftsmouth_l)
            var giftsmouth_all = giftsmouth_l + '.' + giftsmouth_r + "万"
            that.setData({
              giftsmouth_l: giftsmouth_l,
              giftsmouth_r: giftsmouth_r,
              giftsmouth_all: giftsmouth_all
            })
            console.log(giftsmouth_all)
          } else {
            that.setData({
              giftsmouth_all: e.data.data.total_data.giftsmouth.data
            })
          }
          //push合成新数组
          var guilds = e.data.data.guilds;
          var quick_guild = e.data.data.quick_guild;
          var p1_guilds = [];
          p1_guilds.push(...guilds)
          p1_guilds.push(...quick_guild)


          that.setData({
            // p1_quick_guild: e.data.data.quick_guild,//快速选择

            p1_guilds: p1_guilds,
            p1_total_data: e.data.data.total_data,
          })
          console.log(p1_guilds)
          if (e.data.data.total_data.income_diamond) {
            var diamond_int = parseInt(e.data.data.total_data.income_diamond.data)
            var diamond_ceil = Math.ceil(diamond_int).toString()
            that.setData({
              pj_total: diamond_ceil
            })

          } else {
            var gift_int = parseInt(e.data.data.total_data.gifts.data)
            var gift_ceil = Math.ceil(gift_int).toString()
            that.setData({
              pj_total: gift_ceil
            })
          }
          // console.log(that.data.pj_total);
          if (that.data.pj_total.length > 4) {

            var gift_pj_1 = that.data.pj_total.slice(-4); //后面四位
            var gift_pj_2 = that.data.pj_total.slice(0, -4) + '.'
            // console.log('显示万')
            if (that.data.pj_total.length >= 9) {
              // console.log('显示亿')
              that.setData({
                show_yi: true
              })
            } else {
              // console.log('隐藏亿')
              that.setData({
                show_yi: false
              })
            }
            that.setData({
              show_wan: true,
              gift_pj_1: gift_pj_1,
              gift_pj_2: gift_pj_2
            })
          } else {
            // console.log('不到万，走这里')
            // console.log('隐藏万')
            that.setData({
              show_wan: false,
              gift_pj_1: '',
              gift_pj_2: that.data.pj_total
            })
            // console.log(that.data.show_wan)
          }
        }
      });
    } else {
      wx.request({
        method: 'POST',
        url: app.globalData.url + 'api/report/index/mainnew',
        data: {
          token: app.globalData.token,
          guild_id: this.data.guild_id,
          start_date: this.data.start_date,
          end_date: this.data.end_date
        },
        success: function(e) {
          // console.log(e.data.code)
          //没有公会
          if (e.data.code == "1001") {
            that.setData({
              kong: true,
            })
            wx.hideLoading()
          }
          // console.log(e.data.data.guilds["0"].status)
          if (e.data.data.guilds==""){
            var new_guild_id = e.data.data.quick_guild["0"].guild_id
            var new_status = e.data.data.quick_guild["0"].status
          }else{
            var new_guild_id = e.data.data.guilds["0"].guild_id
            var new_status = e.data.data.guilds["0"].status
          }
          that.setData({
            guild_id: new_guild_id,
            status: new_status,
          })
          console.log(that.data.guild_id)
          var giftsmouth = e.data.data.total_data.giftsmouth.data;


          if (giftsmouth.length > 4) {
            var giftsmouth_r = giftsmouth.slice(-4).slice(0, 1)
            var giftsmouth_l = giftsmouth.slice(0, -4)
            // console.log(giftsmouth_r)
            // console.log(giftsmouth_l)
            var giftsmouth_all = giftsmouth_l + '.' + giftsmouth_r + "万"
            that.setData({
              giftsmouth_l: giftsmouth_l,
              giftsmouth_r: giftsmouth_r,
              giftsmouth_all: giftsmouth_all
            })
            console.log(giftsmouth_all)
          } else {
            that.setData({
              giftsmouth_all: e.data.data.total_data.giftsmouth.data
            })
          }
          //push合成新数组
          var guilds = e.data.data.guilds;
          var quick_guild = e.data.data.quick_guild;
          var p1_guilds = [];
          p1_guilds.push(...guilds)
          p1_guilds.push(...quick_guild)


          that.setData({
            // p1_quick_guild: e.data.data.quick_guild,//快速选择

            p1_guilds: p1_guilds,
            p1_total_data: e.data.data.total_data,
          })
          if (e.data.data.total_data.income_diamond) {
            var diamond_int = parseInt(e.data.data.total_data.income_diamond.data)
            var diamond_ceil = Math.ceil(diamond_int).toString()
            that.setData({
              pj_total: diamond_ceil
            })

          } else {
            var gift_int = parseInt(e.data.data.total_data.gifts.data)
            var gift_ceil = Math.ceil(gift_int).toString()
            that.setData({
              pj_total: gift_ceil
            })
          }
          // console.log(that.data.pj_total);
          if (that.data.pj_total.length > 4) {

            var gift_pj_1 = that.data.pj_total.slice(-4); //后面四位
            var gift_pj_2 = that.data.pj_total.slice(0, -4) + '.'
            // console.log('显示万')
            if (that.data.pj_total.length >= 9) {
              // console.log('显示亿')
              that.setData({
                show_yi: true
              })
            } else {
              // console.log('隐藏亿')
              that.setData({
                show_yi: false
              })
            }
            that.setData({
              show_wan: true,
              gift_pj_1: gift_pj_1,
              gift_pj_2: gift_pj_2
            })
          } else {
            // console.log('不到万，走这里')
            // console.log('隐藏万')
            that.setData({
              show_wan: false,
              gift_pj_1: '',
              gift_pj_2: that.data.pj_total
            })
            // console.log(that.data.show_wan)
          }
        }
      });
    }

    //排行数据
    setTimeout(function() {
      if (app.register_info.register_role == 2) {
        if (that.data.table_flag) {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/topnew',
            data: {
              guild_id: that.data.guild_id,
              token: app.globalData.token,
              start_date: that.data.start_date,
              end_date: that.data.end_date,
              quick: "1",
              table_flag: that.data.table_flag,
            },
            success: function(e) {
              // console.log(e)
              var p1_top_data = e.data.data.anchor_top[that.data.index].data.data;
              var p1_top_name = e.data.data.anchor_top[that.data.index].name;
              var foot_name = e.data.data.anchor_top;
              // console.log(foot_name)
              that.setData({
                p1_top_data: p1_top_data,
                p1_top_name: p1_top_name,
                foot_name: foot_name
              })
              wx.hideLoading()
            }

          })
        } else {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/topnew',
            data: {
              guild_id: that.data.guild_id,
              token: app.globalData.token,
              start_date: that.data.start_date,
              end_date: that.data.end_date
            },
            success: function(e) {
              console.log(e)
              var p1_top_data = e.data.data.top_data[that.data.index].data.data;
              var p1_top_name = e.data.data.top_data[that.data.index].name;
              var foot_name = e.data.data.top_data;
              // console.log(foot_name)
              that.setData({
                p1_top_data: p1_top_data,
                p1_top_name: p1_top_name,
                foot_name: foot_name
              })
              wx.hideLoading()
            }

          })
        }

      } else {
        if (that.data.table_flag) {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/topnew',
            data: {
              guild_id: that.data.guild_id,
              token: app.globalData.token,
              start_date: that.data.start_date,
              end_date: that.data.end_date,
              quick: "1",
              table_flag: that.data.table_flag,
            },
            success: function(e) {
              console.log(e)
              var p1_top_data = e.data.data.top_data[that.data.index].data.data;
              var p1_top_name = e.data.data.top_data[that.data.index].name;
              var foot_name = e.data.data.top_data;
              // console.log(foot_name)
              that.setData({
                p1_top_data: p1_top_data,
                p1_top_name: p1_top_name,
                foot_name: foot_name
              })
              wx.hideLoading()
            }

          })
        } else {
          wx.request({
            method: 'POST',
            url: app.globalData.url + 'api/report/index/topnew',
            data: {
              guild_id: that.data.guild_id,
              token: app.globalData.token,
              start_date: that.data.start_date,
              end_date: that.data.end_date
            },
            success: function(e) {
              console.log(e)
              var p1_top_data = e.data.data.top_data[that.data.index].data.data;
              var p1_top_name = e.data.data.top_data[that.data.index].name;
              var foot_name = e.data.data.top_data;
              // console.log(foot_name)
              that.setData({
                p1_top_data: p1_top_data,
                p1_top_name: p1_top_name,
                foot_name: foot_name
              })
              wx.hideLoading()
            }

          })
        }

      }
    }, 200)



  },

  footerTap: app.footerTap
})